package yf;
import io.restassured.RestAssured;
import org.testng.Assert;
import yf.annotations.DataSource;
import io.restassured.response.Response;
import org.testng.annotations.Test;
import yf.asserts.Asserts;
import yf.common.RunBaseCase;
import yf.common.setUpTearDown;
import yf.utils.GetFileMess;


import java.io.IOException;
import java.sql.SQLException;

import static yf.asserts.Asserts.asserts;

//import static io.restassured.module.jsv.JsonSchemaValidator.*;
//
public class AssurePractise extends setUpTearDown{
    @Test
    @DataSource(filePath = "/testCase/login.xlsx",sheetName = "登录",upSqlName = "role",downSqlName = "tearDownSQL")
    public void assureTest(String bodyString, String caseMessMap) throws SQLException, IOException, ClassNotFoundException {
        //初始化数据
        dataSetUp();
        String caseNo=new GetFileMess().getCaseMessKeyValue(caseMessMap, "caseNo");
        String testPoint=new GetFileMess().getCaseMessKeyValue(caseMessMap, "testPoint");
        String requestType=new GetFileMess().getCaseMessKeyValue(caseMessMap,"requestType");
        String path=new GetFileMess().getCaseMessKeyValue(caseMessMap,"path");
        Response response= RunBaseCase.runCase(bodyString,requestType,path);
        asserts(caseMessMap,bodyString,response);
        dataTearDown();


//        String url = RestAssured.baseURI + ":" + RestAssured.port + "/"+path ;

    }
//@DataProvider(name = "user")
//public Object[][] user1() throws IOException {
//    TestCase testCase= GetTestCase.getTestCase( "/testCase/login.xlsx","登录");
//    Object[][] objects = new Object[testCase.getCases().size()][3];
//    for(int i=0;i<testCase.getCases().size();i++){
//        objects[i][0]=testCase.getCases().get(i).getTestCaseNo();
//        objects[i][1]=testCase.getCases().get(i).getParameter();
//        objects[i][2]=testCase.getMethod();
//    }
//    return objects;
//}

//    @Test(dataProvider = "user")
//    public void assureTest1(String testCaseNo,String bodyString,String reqestType){
//        System.out.println(testCaseNo);
//       System.out.println(bodyString);
//        System.out.println(reqestType);
//        System.out.println("ceshi");
//    }
}

